package cn.cmcc.online.smsapi.ui.model;

import android.graphics.Color;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Created by ZhangYifan on 2017/6/16.
 */

public class CommonData {
    private int color;
    private String highInfoTitle;
    private String highInfoValue;
    private Map<String, String> mainInfoDadaArr;
    private Map<String, String> extraInfoDataArr;
    private String extraInfoTip;

    public CommonData(JSONObject obj) {
        color = Color.parseColor(obj.optString("title_color", "#123456"));
        // TODO: 2017/6/18  
        JSONObject data = obj.optJSONObject("data");
        highInfoTitle = data.optString("high_info_title");
        highInfoValue = data.optString("high_info_value");

        mainInfoDadaArr = new LinkedHashMap<>();
        JSONArray importArray = data.optJSONArray("main_info_data_arr");
        if (importArray != null) {
            for (int i = 0; i < importArray.length(); i++) {
                JSONObject key_value = importArray.optJSONObject(i);
                mainInfoDadaArr.put(key_value.optString("key"), key_value.optString("value"));
            }
        }

        extraInfoDataArr = new LinkedHashMap<>();
        JSONArray lessimportArray = data.optJSONArray("extra_info_data_arr");
        if (lessimportArray != null) {
            for (int i = 0; i < lessimportArray.length(); i++) {
                JSONObject key_value = lessimportArray.optJSONObject(i);
                extraInfoDataArr.put(key_value.optString("key"), key_value.optString("value"));
            }
        }

        extraInfoTip = data.optString("extra_info_tip");

    }

    public int getColor() {
        return color;
    }

    public String getHighInfoTitle() {
        return highInfoTitle;
    }

    public String getHighInfoValue() {
        return highInfoValue;
    }

    public Map<String, String> getMainInfoDadaArr() {
        return mainInfoDadaArr;
    }

    public Map<String, String> getExtraInfoDataArr() {
        return extraInfoDataArr;
    }

    public String getExtraInfoTip() {
        return extraInfoTip;
    }
}
